package com.sqlcheck.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("compatibility_rules")
public class CompatibilityRule {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("rule_id")
    private String ruleId;

    @TableField("rule_name")
    private String ruleName;

    @TableField("category")
    private String category;

    @TableField("source_db_type")
    private DbType sourceDbType;

    @TableField("target_db_type")
    private DbType targetDbType;

    @TableField("rule_pattern")
    private String rulePattern;

    @TableField("severity")
    private Severity severity;

    @TableField("description")
    private String description;

    @TableField("suggestion")
    private String suggestion;

    @TableField("example_sql")
    private String exampleSql;

    @TableField("suggested_sql")
    private String suggestedSql;

    @TableField("fallback_pattern")
    private String fallbackPattern;

    @TableField("is_active")
    private Boolean isActive;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @TableLogic
    @TableField("deleted")
    private Boolean deleted;

    public enum DbType {
        MYSQL, ORACLE, POSTGRESQL, SQLSERVER, GOLDENDB
    }

    public enum Severity {
        HIGH, MEDIUM, LOW, INFO
    }
}